<?php
/**
 * @copyright	Copyright (C) 2007 ID Society. All rights reserved.
 */
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

// Defaults
$menu_active_id = '1';
$section_alias = 'new-york';

// Get the menu object
$menu	= &JSite::getMenu();

/**
 * Get ID of active menu item to pass to Flash
 */

// If active ID is below sublevel navigation, find the sublevel 
// parent ID to send to Flash

$menu_active	= $menu->getActive();
if (isset($menu_active)) {
	$menu_active_id = $menu_active->id;
	$menu_active_level = $menu_active->sublevel;
	
	while ($menu_active_level > 2) {
		$menu_active_id = $menu_active->parent;
		$menu_active = $menu->getItems('id', $menu_active_id, 'true');
		$menu_active_level = $menu_active->sublevel;
	}
}


/**
 * Get alias of selected global section to define page style
 */

// default: new york
$section_alias = 'new-york';

$menu_active2 = $menu_active;
if (isset($menu_active2)) {
	$menu_active2_id = $menu_active2->id;
	$menu_active2_level = $menu_active2->sublevel;
	
	while ($menu_active2_level > 0) {
		$menu_active2_id = $menu_active2->parent;
		$menu_active2 = $menu->getItems('id', $menu_active2_id, 'true');
		$menu_active2_level = $menu_active2->sublevel;
	}
	
	$section_alias = $menu_active2->alias;
}


/**
 * Get selected page template
 */
 
$page_template = $mainframe->getTemplate();


/**
 * Get the proper title to use on the page.
 * We are modifying the browser title for our custom 
 * components, so for those pages, we need to specify
 * a different page title.
 */

$component_array = Array('com_calendar', 'com_collections', 'com_gugg_images',
						 'com_pastexhibits', 'com_phocagallery');
$fa_url = 'archive-collections';

if (isset($menu_active)) {
	$component = $menu_active->component;
} else {
	$component = 'com_content';
}

// For custom components, we want the page title to be the 
// name of the component
if (in_array($component, $component_array)) {
	// Exception for Past Exhibitions
	if ($component == 'com_pastexhibits') {
		$page_title = 'Past Exhibitions';
	} else {
		$page_title = $menu->getActive()->name;
	}

// For some reason, Finding Aids is not detected as a component, so 
// we need a manual check for that section. Main page's page title should 
// be the name of the component, detail pages' page titles should be 
// the name of the finding aid
} else if (stripos($_SERVER['REQUEST_URI'], $fa_url) !== false) {
	$page_title = 'Archives Collections';
	
	// Only want to modify the title if we're on a detail page
	$url_array = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
	if (array_search($fa_url, $url_array) < (count($url_array) - 1)) {
		$title_array = explode('|', $this->getTitle());
		if (isset($title_array[1])) {
			$page_title = $title_array[1];
		}
	}

// For all other pages, we do not need to modify the page title
} else {
	$page_title = $this->getTitle();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" >
<head>
<meta name="verify-v1" content="CHa7vMS5jRJn8vtJv3nK7nj/ocuCBnDYr2GNkSmzKLI=" />
<jdoc:include type="head" />
	<link href="/images/favicon.ico" rel="shortcut icon"/>
	<link rel="stylesheet" href="/templates/guggenheim/css/style.css" type="text/css" charset="utf-8" />
	<?php 
		if (strtolower($page_title) == 'calendar and events') {
	?>
<link href="/new-york/calendar-and-events?format=feed&amp;type=rss" rel="alternate" type="application/rss+xml" title="RSS 2.0" />
<link href="/new-york/calendar-and-events?format=feed&amp;type=atom" rel="alternate" type="application/atom+xml" title="Atom 1.0" />
	<?php
		}
	?>

	<!-- gugg requested adjustments -->
	<script type="text/javascript" src="/includes/js/jquery-1.3.2.min.js"></script>
	<script type="text/javascript" src="/includes/js/jquery.qtip.min.js" ></script>
	<!-- gugg requested adjustments -->
			
		
	<script type="text/javascript" src="/templates/guggenheim/js/guggenheim.min.js"></script>
	<!--no conflict toggle -->
	<script type="text/javascript">
	<?php $pageoption1 = JRequest::getVar( 'option', '' );
	if ($pageoption1 == 'com_arts_curriculum') {
	echo '';
	}else{
 	echo 'jQuery.noConflict();';
	} ?>
	</script>

	<script type="text/javascript" src="/templates/guggenheim/js/jPrintArea.js"></script>
	<!--no conflict toggle part2 -->
	<?php if ($pageoption1 == 'com_arts_curriculum') { 
	echo' <script src="http://sandbox.guggenheim.org/components/com_arts_curriculum/js/jquery-1.1.3.1.pack.js" type="text/javascript"></script>
   	<script src="http://sandbox.guggenheim.org/components/com_arts_curriculum/js/jquery.history_remote.pack.js" type="text/javascript"></script>
   	<script src="http://sandbox.guggenheim.org/components/com_arts_curriculum/js/jquery.tabs.pack.js" type="text/javascript"></script>
  	<script type="text/javascript">
            $(function() {
                $(\'#container-1\').tabs(3);           
            });
        </script>
	<link rel="stylesheet" href="http://sandbox.guggenheim.org/components/com_arts_curriculum/js/jquery.tabs.css" type="text/css" media="print, projection, screen">';} ?>
	
	
<!--We need to alter the body tag for the sketchup component that loads the GE plug-in-->
<?php
$pageoption = JRequest::getVar( 'option', '' );
if ($pageoption == 'com_sketchup') {
$bodytag = 'onload=\'init()\'';
}
else{
$bodytag ='';
}
?>
</head>
<body <?php echo $bodytag;?> id="<?= $section_alias; ?>" class="<?php echo $page_template;?>" >

<div id="wrapper">
	<div id="header"><!--googleoff: all-->
			<jdoc:include type="modules" name="user3" style="" headerLevel="3" />
<script type="text/javascript">
  ids.flash.add('header', {
	movie: '/templates/guggenheim/flash/gug_nav.swf',
	id: 'gugg_flash',
	width: '940', 
	height: '203',
	flashvars: "Atlocale=<?=$menu_active_id;?>", 
	quality: 'high', 
	wmode: 'opaque', 
	bgcolor: '#e6e6e6', 
	version: '8',
	className: "fr"

});

jQuery(document).ready(function() {
  if (jQuery("#nyflash").is("div")) {
      ids.flash.replace('nyflash', {
    	movie: '/templates/guggenheim/flash/rolling_vignette.swf',
    	id: 'ny-flash', 
    	width: '690', 
    	height: '235',
    	flashvars: "myxml=/lib/ny_vigcontent.xml", 
    	quality: 'high', 
    	wmode: 'opaque', 
    	bgcolor: '#e6e6e6', 
    	version: '8',
    	className: "fr"
    }); 
  };

  jQuery("#event-select").next().click(function(){
	window.location.href = "<?= JRoute::_('index.php?option=com_phocagallery&view=category');?>/events/"+jQuery(this).prev().val();
	return false;
   })
   
  jQuery("#location-select").next().click(function(){
	window.location.href = "<?= JRoute::_('index.php?option=com_phocagallery&view=category');?>/location/"+jQuery(this).prev().val();
	return false;
   })
   
   jQuery("#pastex-select").click(function(){
	window.location = "<?= JRoute::_('index.php?option=com_pastexhibits&view=search');?>/list/exhibition"+jQuery(this).prev().val();
	return false;
   })  
	
	
	jQuery('#pastex-filter').click(function(){
		var past_ex_us = "";
		var past_ex_yr = jQuery('#year-select').val();
		var past_ex_loc = jQuery('#location-select').val();

		if (past_ex_yr != 'all'){
				if (past_ex_loc != 'all'){
					var past_ex_us = "_";
				}
		}else{
			var past_ex_yr = "";
		}
		if (past_ex_loc == 'all'){
			var past_ex_us = "";
		}
		if (past_ex_yr &&  past_ex_loc == 'all'){
			var past_ex_loc = "";
		}

	  window.location = "<?= JRoute::_('index.php?option=com_pastexhibits&view=search');?>/list/" +  past_ex_yr + past_ex_us + past_ex_loc; 
	  return false;
  	});
  	
  	jQuery('.print').click(function(){ jQuery.jPrintArea('#content'); return false;});

});



var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height, scrollbarNeed)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scrollbarNeed+',resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

</script>
<!--<span>To view this section you must have Flash Player Version 8 installed on your machine Click <a href=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\">Here</a> to update your Flash Player. Once you have installed the latest Flash Player, you will need to quit your browser , relaunch it to the Guggenheim website.</span>-->
<!--googleon: all-->
	</div>
	<jdoc:include type="modules" name="calendar" style="" headerLevel="3" />
	<div id="content" class="printArea">
        <!-- added by cjb 2/9/09 for notice module -->
        <div id="notice"><jdoc:include type="modules" name="user1" style="" headerLevel="3" /></div>
		  <!-- end added by cjb 2/9/09 for notice module -->
		<div id="title-bar">
			<jdoc:include type="modules" name="search" style="" headerLevel="3" />
		<h1><?= htmlspecialchars($page_title); ?></h1>
		</div>
